//
//  PingTeBottomView.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/27.
//

#import "PingTeBottomView.h"
#import "CommonUtil.h"


@interface PingTeBottomView()
@property (strong, nonatomic) UIView * line1;
@property (strong, nonatomic) UIView * line2;
@property (strong, nonatomic) UIButton * giveBtn;
@property (strong, nonatomic) UIButton * addFridentBtn;
@property (strong, nonatomic) UIButton * followBtn;

@property (strong, nonatomic) UIView * hudView;

@end

@implementation PingTeBottomView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.giveBtn];
        [self addSubview:self.addFridentBtn];
        [self addSubview:self.line1];
        [self addSubview:self.line2];
        [self addSubview:self.followBtn];
        [self addSubview:self.hudView];
        self.followBtn.centerY = self.giveBtn.centerY;
    }
    return self;
}

- (void)giveBtnClick:(UIButton *)sender{
    BaseAlert *alert = [HudFactory creatHudWithType:@"rewardMoneyAlert"];
    [alert show];
}

- (void)addFridentClick:(UIButton *)sender{
    BaseAlert *alert = [HudFactory creatHudWithType:@"AddFriendAlert"];
    [alert show];
}

- (void)followClick:(UIButton *)sender{
    NSLog(@"关注");
    self.hudView.hidden = false;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.hudView.hidden = YES;
    });
    
}

- (void)lookClick:(UIButton *)sender{
    NSLog(@"查看");

    
}


-(UIView *)line1{
    if (!_line1) {
        _line1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, AD(1))];
        _line1.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.5];
    }
    return _line1;
}

-(UIView *)line2{
    if (!_line2) {
        _line2 = [[UIView alloc] initWithFrame:CGRectMake(_giveBtn.right, AD(20), AD(1), AD(20))];
        _line2.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.5];
    }
    return _line2;
}


-(UIButton *)giveBtn{
    if (!_giveBtn) {
        _giveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _giveBtn.frame = CGRectMake(0, 0, AD(100), AD(60));
        _giveBtn.titleLabel.font = [UIFont systemFontOfSize:AD(18)];
        [_giveBtn setTitle:@"打赏" forState:UIControlStateNormal];
        [_giveBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_giveBtn setImage:[UIImage imageNamed:@"icon_dashang"] forState:UIControlStateNormal];
        _giveBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -AD(10));
        [_giveBtn addTarget:self action:@selector(giveBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _giveBtn;
}


-(UIButton *)addFridentBtn{
    if (!_addFridentBtn) {
        _addFridentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _addFridentBtn.frame = CGRectMake(_giveBtn.right, 0, AD(100), AD(60));
        _addFridentBtn.titleLabel.font = [UIFont systemFontOfSize:AD(18)];
        [_addFridentBtn setTitle:@"加好友" forState:UIControlStateNormal];
        [_addFridentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_addFridentBtn setImage:[UIImage imageNamed:@"icon_addfrident"] forState:UIControlStateNormal];
        _addFridentBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -AD(10));
        [_addFridentBtn addTarget:self action:@selector(addFridentClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _addFridentBtn;
}


-(UIButton *)followBtn{
    if (!_followBtn) {
        _followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _followBtn.frame = CGRectMake(_addFridentBtn.right+AD(5), 0, AD(150), AD(40));
        _followBtn.titleLabel.font = [UIFont systemFontOfSize:AD(20)];
        [_followBtn setTitle:@"+ 关注" forState:UIControlStateNormal];
        [_followBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_followBtn addTarget:self action:@selector(followClick:) forControlEvents:UIControlEventTouchUpInside];
        _followBtn.backgroundColor = RGB(255.0, 99.0, 32.0);
        _followBtn.layer.cornerRadius = AD(20);
        _followBtn.clipsToBounds = YES;
    }
    return _followBtn;
}

-(UIView *)hudView{
    if (!_hudView) {
        _hudView = [[UIView alloc] initWithFrame:CGRectMake(AD(30), AD(20), SCREEN_WIDTH-AD(60), AD(40))];
        _hudView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        _hudView.hidden = YES;
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(AD(30), 0, AD(100), AD(40))];
        titleLabel.text = @"已添加统计";
        titleLabel.font = [UIFont systemFontOfSize:AD(16)];
        titleLabel.textColor = [UIColor whiteColor];
        [_hudView addSubview:titleLabel];
     
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setTitle:@"查看" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
        btn.frame = CGRectMake(_hudView.width - AD(80), 0, AD(50), AD(40));
        [btn addTarget:self action:@selector(lookClick:) forControlEvents:UIControlEventTouchUpInside];
        [_hudView addSubview:btn];
        
    }
    return _hudView;
}

@end
